package com.jt.www.enums.issue;

import org.apache.commons.lang3.StringUtils;

/**
 * 出单ifCode or 电子保单ifCode 映射
 */
public enum InvoiceTypeEnum {

    ELECTRONIC_INVOICE("00", "电子发票"),
    PAPER_EXCLUSIVE("01", "纸质专票"),
    PAPER_ORDINARY("02", "纸质普票"),
    BLUE_INVOICE("1", "蓝票"),
    REA_INVOICE("2", "红票");


    /**
     * 类型
     */
    private String type;
    /**
     * 描述
     */
    private String desc;

    InvoiceTypeEnum(String type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    /**
     * 通过type得到描述
     *
     * @param type
     * @return
     */
    public static String getDescByType(String type) {
        if (StringUtils.isBlank(type)) {
            return "";
        }
        for (InvoiceTypeEnum invoiceTypeEnum : InvoiceTypeEnum.values()) {
            if (invoiceTypeEnum.type.equals(type)) {
                return invoiceTypeEnum.getDesc();
            }
        }
        return "";
    }

    public String getType() {
        return type;
    }

    public String getDesc() {
        return desc;
    }
}
